package com.example.demo;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.cloud.stream.messaging.Source;

/**
 * 接受rabbitmq 消息的消费者
 * 
 * @author binbin.zhang
 *
 */
//Sink接口是Spring cloud Stream中默认实现的对输入消息通道绑定的定义。除了sink还有默认实现绑定output的source接口
//还有结合了input和output的processor接口,实际使用中 我们也可以自定义接口
//EnableBinding可以指定多个接口@EnableBinding(Sink.class,Source.class)
@EnableBinding(value = { Sink.class })
public class SinkReceiver {
	private static Logger logger = LoggerFactory.getLogger(SinkReceiver.class);

	// 消息监听
	@StreamListener(Sink.INPUT)
	public void receive(Object payload) {
		logger.info("Received:" + payload);
	}
}
